import { getPublicModelList } from "@/api";
import config from "@/common/config";
import storage from "@/common/function/storage";
import { getSearchFilter } from "@/common/function";
const state = {
  // 订单状态
  dictionaryData: {},
  userMenuList: [],
};

const mutations = {
  SET_DICTIONARY_LIST(state, data) {
    state.userMenuList = data;
  },
  SET_DICTIONARY_DATA(state, data) {
    state.dictionaryData = data;
  },
};

const actions = {
  // 获取订单状态列表数据
  async getOrderStatusList({ commit }) {
    // 订单
    const params = {};
    let filterData = {
      currentPage: 1,
      pageSize: -1,
      filter: getSearchFilter({ key: "order_status" }, { method: "eq" }),
    };
    const { data } = await getPublicModelList(
      "65e032fc5efd5153ff5645fb",
      filterData
    );
    // 订单分类
    data?.list?.[0]?.tableField103?.slice(0, -1)?.forEach((item) => {
      params[item.status] = {
        code: item.code,
        url: item.img[0]?.url,
      };
    });
    let arr = Object.keys(params).map((item) => ({
      img: config.baseURL + params?.[item].url,
      name: item,
      code: params?.[item].code,
    }));
    // 项目排序分类
    commit("SET_DICTIONARY_DATA", params);
    commit("SET_DICTIONARY_LIST", arr);
  },
};

const getters = {};

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters,
};
